package personal.xjl.studentdemo.dao;

import org.apache.ibatis.annotations.*;
import personal.xjl.studentdemo.entity.Student;

import java.util.List;

@Mapper           //Mybatis数据访问对象，默认名称studentMapper
public interface StudentMapper {
    @Select("select * from student limit #{fromIndex},#{pageSize}")
    public List<Student> findAll(@Param("fromIndex") int fromIndex,@Param("pageSize") int pageSize);
    @Delete("delete from student where id=#{id}")
    public int deleteById( int id);
    @Insert("insert into student(id, name, password, sex, clazz, birthday) values(#{id},#{name},#{password},#{sex},#{clazz},#{birthday})")
    public int insert(Student student);
    @Select("select * from student where id=#{id}")
    Student selectById(int id);
    @Update("update student set name=#{name},password=#{password},sex=#{sex},clazz=#{clazz},birthday=#{birthday} where id=#{id}")
    int update(Student student);
    @Select("select * from student where name=#{username} and password=#{password}")
    public List<Student> selectByUsernameAndPass(@Param("username") String username,@Param("password") String password);
}
